<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<%@ page import="org.springside.core.Constants"%>
<%@ page import="org.springside.core.utils.DateUtil"%>
<%@ page import="cn.firstsoft.firstframe.admin.PropertyFile"%>
<%@ page import="org.apache.commons.fileupload.*"%>
<%@ page import="org.apache.commons.fileupload.servlet.*"%>
<%@ page import="org.apache.commons.fileupload.disk.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.io.*"%>

<%
	boolean flag = false;
	String licPath = System.getProperty("oa_application.config") + File.separator + "license";
	String propertiesPath = System.getProperty("oa_application.config") + File.separator + "license.properties";
	String uploadPath = licPath;

	try{
	   FileItemFactory factory = new DiskFileItemFactory();
	   ServletFileUpload upload = new ServletFileUpload(factory);
	   List<FileItem> items = upload.parseRequest(request);//得到所有的文件
		Iterator<FileItem> itr = items.iterator();
		while(itr.hasNext()){//依次处理每个文件
	    FileItem item=(FileItem)itr.next();
	    String fileName=item.getName();//获得文件名，包括路径
		    if(fileName!=null){
		        File fullFile=new File(item.getName());
		        
		        if(fullFile.getName().equals("license.properties")) uploadPath = propertiesPath;
		        File savedFile=new File(uploadPath);
		        item.write(savedFile);
		        flag = true;
		        break;
			}
		}
	}catch(Exception e){
        e.printStackTrace();
    }


%>

<%if(flag){ %> 上传成功。重启后生效。<%} %>
<%if(!flag){ %> 上传失败。<%} %>
